package com.haibara.aioj.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.haibara.aioj.model.entity.QuestionSubmit;
import com.haibara.aioj.model.vo.QuestionSubmitViewVO;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author AiChan
* @description 针对表【question_sumbit(题目提交)】的数据库操作Mapper
* @createDate 2023-12-20 13:17:36
* @Entity generator.domain.QuestionSubmit
*/
@Mapper
public interface QuestionSubmitMapper extends BaseMapper<QuestionSubmit> {
    /**
     * 查询数量
     *
     * @param title    标题
     * @param language 语言
     * @return long
     */
    long countQuestionSubmit(@Param("title") String title, @Param("language") String language);

    List<QuestionSubmitViewVO> selectQuestionSubmit(@Param("title") String title, @Param("language") String language, @Param("pageIndex") long pageIndex, @Param("size") long size);


    @Select("SELECT qs.code " +
            "FROM question_submit qs " +
            "WHERE qs.questionId = #{questionId} AND qs.userId = #{userId} " +
            "ORDER BY updateTime DESC " +
            "LIMIT 0,1")
    String getHistoryCode(@Param("questionId") Long questionId, @Param("userId") Long userId);
}




